package net.cohoivang.core;

import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import net.cohoivang.news.News;

public class Company {
	int companyId;	
	String legalName;
	String englishName;
	String shortName;
	String address1;
	String phone;
	String fax;
	String email;
	String website;
	String description;
	Industry industry;
	Sector sector;
	Date createDate;
	Date updateDate;
	
	List<News> newss = new LinkedList<News>();
	
	

	public int getCompanyId() {
		return companyId;
	}

	
	public String getLegalName() {
		return legalName;
	}

	
	public Company(String legalName, String englishName) {
		this.legalName = legalName;
		this.englishName = englishName;
	}
	
	public Company(int id, String legalName, String englishName, String shortName, String address1, String phone, String fax,
			String email, String website, String description, Industry industry,
			Date createDate, Date updateDate, Sector sector) {
		this.companyId = id;
		this.legalName = legalName;
		this.englishName = englishName;
		this.shortName = shortName;
		this.address1 = address1;
		this.phone = phone;
		this.fax = fax;
		this.email = email;
		this.website = website;
		this.description = description;
		this.industry = industry;		
		this.createDate = createDate;
		this.updateDate = updateDate;
		this.sector = sector;
	}
	
	public News createNews(int newsId, int industryId, int sectorId, Date createDate,
			String createBy, Date lastUpdateDate, String lastUpdateBy, int isReviewed, int isTop, 
			int expiredTime, int currentTime) {
		News news = new News(newsId, createDate, createBy, lastUpdateDate, lastUpdateBy, isReviewed, isTop,
				expiredTime, currentTime);
		Industry indus = ProfileCompany.getInstance().findIndustry(industryId);
		if (indus == null) {
			return null;
		}
		Sector sect = ProfileCompany.getInstance().findSector(sectorId);
		
		if (sect == null) {
			return null;
		}		
		
		news.setIndtustry(indus);
		news.setSector(sect);
		return news;
	}
	
	public LinkedList<News> getAllNews() {
		synchronized (newss) {
			return new LinkedList<News>(newss);
		}
	}
}
